package inherit;

import inner.Test3;

class Animals {
    public Dog[] dogs;
    public Cat[] cats;
    int age;
    String name;
    String sex;
    private int num = 001;


    public Animals(int age, String name, String sex) {
        this.age = age;
        this.name = name;
        this.sex = sex;
    }

    public int getNum() {
        return num;
    }

    public void body() {
        System.out.println(name + "健康");
    }
}

class Dog extends Animals {
    public int num;

    public Dog(int age, String name, String sex, int num) {
        //先帮助父类部分初始化
        super(5, "02", "man");
        this.num = 02;
    }

    @Override
    public void body() {
        System.out.println(name+"正常");
    }

    @Override
    public String toString() {
        System.out.println("aaa");
        return "bb";
    }

    public void eat() {
        System.out.println(name + "吃东西");
    }
}

class Cat extends Animals {
    public Cat(){
        super(2,"22","wm");

    }

    @Override
    public void body() {
        System.out.println(name+"well");
    }

    public void sleep() {
        System.out.println(name + "睡觉");
    }
}


public class Test extends Test3 {
    public static void func(Animals animals){
    animals.body();
    }
    public static Animals test2(){
        return new Cat();
    }

    public static void main(String[] args) {
        Dog dog = new Dog(10,"1","2",3);
        func(dog);
        Animals animals=new Cat();
        func(animals);
        if(animals instanceof Dog) {
                Cat cat = (Cat) animals;
                cat.sleep();
        }
    }
    public  void test() {
    Test3 t=new Test3();
        System.out.println(super.a);

    }

    public static void main3(String[] args) {
        Test test=new Test();
        test.test();
    }
    public static void main2(String[] args) {
        Dog dog = new Dog(10,"1","2",3);
        Animals ani=dog;
        Animals ani2=new Dog(20,"sg","w",6);
        ani.body();
        func(dog);
        /*dog.age = 5;
        dog.name = "s";
        dog.sex = "man";
        dog.eat();
        dog.body();
        System.out.println(dog.getNum());
        System.out.println(dog);*/
    }
}
